#ifndef __UTIL__UNDELETABLE_PTR_HPP__
#define __UTIL__UNDELETABLE_PTR_HPP__

namespace util {
  /** @brief A smart pointer that prevents deletion of what it points
             to.

      This class is adapted from "Unsmart Pointers, Part I: Preventing
      and catching errors" by Christopher Diggins, C/C++ Users Journal
      Vol. 23, No. 7, July 2005.

      A compilation error will occur if delete is called on an
      undeletable pointer.  This pointer class should be used when a
      the object pointed to cannot be deleted.
  */
  template <typename T>
  class undeletable_ptr {
  public:
    undeletable_ptr() : m(0) {}
    undeletable_ptr(const undeletable_ptr& p) : m(p.m) {}
    undeletable_ptr(T* p) : m(p) {};
    T* operator->() const {return m;}
    T& operator*() const {return *m;}
    T* raw() const {return m;}

  private:
    T* m;
  };
}

#endif
